package model.newhouse.controller;

import model.newhouse.entity.Newhouse;
import model.newhouse.entity.Result;
import model.newhouse.entity.StatusCode;
import model.newhouse.service.INewhouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class newhouseController {

    @Autowired
    private INewhouseService newService;
    @GetMapping("/list")
    public Result find(){
        List<Newhouse> newhouseList = newService.findAll();
        Result result = new Result(true, StatusCode.OK,"查询成功",newhouseList);
        return  result;
    }

//    @GetMapping("/findlist/{newhouseMetro},{newhouseSchool},{newhouseCommerce}")
//    public Result findlist(@PathVariable("newhouseMetro") String newhouseMetro,@PathVariable("newhouseSchool") String newhouseSchool,@PathVariable("newhouseCommerce") String newhouseCommerce){
//        List<Newhouse> newhouseList1 =  newService.findByMetro(newhouseMetro,newhouseSchool,newhouseCommerce);
//
//        Result result = new Result(true, StatusCode.OK,"查询成功");
//        return result;
//    }

    @GetMapping("/findlist1/{newhouseMetro}")
    public Result findlist1(@PathVariable("newhouseMetro") String newhouseMetro){
        List<Newhouse> newhouseList1 =  newService.findByMetro(newhouseMetro);

        Result result = new Result(true, StatusCode.OK,"查询成功",newhouseList1);
        System.out.println(result);
        return result;
    }
    @GetMapping("/findlist2/{newhouseSchool}")
    public Result findlist2(@PathVariable("newhouseSchool") String newhouseSchool){
        List<Newhouse> newhouseList1 =  newService.findBySchool(newhouseSchool);

        Result result = new Result(true, StatusCode.OK,"查询成功",newhouseList1);
        return result;
    }
    @GetMapping("/findlist3/{newhouseCommerce}")
    public Result findlist3(@PathVariable("newhouseCommerce") String newhouseCommerce){
        List<Newhouse> newhouseList1 =  newService.findByCommerce(newhouseCommerce);

        Result result = new Result(true, StatusCode.OK,"查询成功",newhouseList1);
        return result;
    }


}
